classdef pH_dev < Processor_dev
  % Class for calculating pH ala SBE Data Procesing
  % Derived from Processor
  % Constructor signature: pH = pH_dev(data, conn, T), args. optional
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A
  
    properties
      % inherited from Processor_dev
%         inData;
%         castDT;
%         scanRate;
%         ParamID;
%         ParamDesc;
%         SBEprec;
%         EquipID;
        DBdata;
        outData;
    end
    
    methods
        function pH = pH_dev(data, conn, T) % Constructor
            if nargin < 1, data = []; end
            if nargin < 2, conn = []; end
            pH = pH@Processor_dev(data);
            if ~isempty(conn), pH.getDBdata(conn, 'H'); end
            if nargin==3, pH.mainFormula(T); end
        end
        
        function delete(obj) % Destructor
            % Here in case I need it
        end
        
        function mainFormula(obj, T)
            m = obj.inData.Sensors.pH_Sensor.Slope;
            b = obj.inData.Sensors.pH_Sensor.Offset;
            K = T + 273.15;
            V = obj.inData.rV(:,obj.inData.Sensors.pH_Sensor.index-2);
            obj.outData = 7.0 + (V - b) ./ (1.98416e-4 * m * K);
        end
        
    end
    
end